#############################################################
#
# Makefile for the tool QDL released by Nodecom
# 
# Copyright (c) 2010 by SIMCOM, Incorporated. All Rights Reserved.
#
# Author: CaoGang
# 
# Date: 2013/09/16
#
############################################################

MAIN_DIR = .
TARGET_BIN_DIR = $(MAIN_DIR)/diaggrabpro_bin
TARGET_OBJ_DIR = $(MAIN_DIR)/diaggrabpro_obj

BIN_NAME  = diaggrabpro

DIAGGRABPRO_DIR = $(MAIN_DIR)

SRC_DIR = $(DIAGGRABPRO_DIR) 

INCLUDE_PREFIX = -I

ALL_PATHS= $(SRC_DIR)

ALL_INCLUDES = $(addprefix $(INCLUDE_PREFIX), $(ALL_PATHS))

OBJ_CMD = -o 

LD_CMD = -o

LD_LIBRARY = -lpthread

DIAGGRABPRO_OBJS =$(TARGET_OBJ_DIR)/diaggrabpro.o 

			   
BIN_OBJS = $(DIAGGRABPRO_OBJS) 

$(TARGET_OBJ_DIR)/%.o:$(DIAGGRABPRO_DIR)/%.c
	@echo ---------------------------------------------------------
	@echo Build OBJECT $(@) from SOURCE $<
	@$(CC) -c $(CFLAGS) $(ALL_INCLUDES) $(OBJ_CMD) $@ $<
	@echo ---------------------------------------------------------

.PHONY: all clean

all:prep bin 

prep:
	@if test ! -d $(TARGET_BIN_DIR); then mkdir $(TARGET_BIN_DIR); fi
	@if test ! -d $(TARGET_OBJ_DIR); then mkdir $(TARGET_OBJ_DIR); fi

bin:$(BIN_OBJS)
	@echo ---------------------------------------------------------
	@echo Create bin file $(BIN_NAME)
	@$(CC) $(LD_CMD) $(TARGET_BIN_DIR)/$(BIN_NAME) $^ $(LD_LIBRARY)
	@echo ---------------------------------------------------------
	
clean:
	@rm -fr $(TARGET_OBJ_DIR) $(TARGET_BIN_DIR) 
	
